package com.wholesmart.web.controller;

import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.wholesmart.common.bean.Message;
import com.wholesmart.common.bean.Page;
import com.wholesmart.mapper.entity.User;
import com.wholesmart.service.UserService;

/**
 * 用户控制器
 * 
 * @author dyw
 * @date 2020年1月8日
 */
@RestController
@RequestMapping("/user")
public class UserController {
	@Autowired
	private UserService userService;

	@GetMapping("/query")
	public User query(@RequestParam(value = "id", required = true) Long id) {
		return null;
	}

	@PostMapping("/save")
	public User save(User user) {
		return null;
	}

	/**
	 * 分页条件查询
	 * 
	 * <pre>
	 * 有效查询条件包括：
	 * 
	 * {"page":{
	 *     "pageSize":10,
	 *     "currentPage":1,
	 *     "orderFile":"id",
	 *     "orderType":"asc"
	 *         },
	 *   "condition"{
	 *      "":"",
	 *      "":"",
	 *      "":""
	 *         }
	 *   }
	 * </pre>
	 *
	 * @param params 分页和条件参数
	 * @return
	 */
	@PostMapping("/query/page")
	public Message queryPage(@RequestBody Map<String, Object> params) {
		Page<User> page = userService.getPage(params);
		return Message.success(page);
	}
}
